home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 317 / asmsrc / messages.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-20  |  3.3 KB  |  131 lines

  1. /* messages.c - error reporter - */
  2.  
  3. /* Copyright (C) 1987 Free Software Foundation, Inc.
  4.  
  5. This file is part of Gas, the GNU Assembler.
  6.  
  7. The GNU assembler is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY.  No author or distributor
  9. accepts responsibility to anyone for the consequences of using it
  10. or for whether it serves any particular purpose or works at all,
  11. unless he says so in writing.  Refer to the GNU Assembler General
  12. Public License for full details.
  13.  
  14. Everyone is granted permission to copy, modify and redistribute
  15. the GNU Assembler, but only under the conditions described in the
  16. GNU Assembler General Public License.  A copy of this license is
  17. supposed to have been given to you along with the GNU Assembler
  18. so you can know your rights and responsibilities.  It should be
  19. in a file named COPYING.  Among other things, the copyright
  20. notice and this notice must be preserved on all copies.  */
  21.  
  22. #include <stdio.h>        /* define stderr */
  23. #include "as.h"
  24. #ifndef NO_VARARGS
  25. #include <varargs.h>
  26. #endif
  27.  
  28. /*
  29.         ERRORS
  30.  
  31.     We print the error message 1st, beginning in column 1.
  32.     All ancillary info starts in column 2 on lines after the
  33.     key error text.
  34.     We try to print a location in logical and physical file
  35.     just after the main error text.
  36.     Caller then prints any appendices after that, begining all
  37.     lines with at least 1 space.
  38.  
  39.     Optionally, we may die.
  40.     There is no need for a trailing '\n' in your error text format
  41.     because we supply one.
  42.  
  43. as_warn(fmt,args)  Like fprintf(stderr,fmt,args) but also call errwhere().
  44.  
  45. as_fatal(fmt,args) Like as_warn() but exit with a fatal status.
  46.  
  47. */
  48.  
  49.  
  50.  
  51. /*
  52.  *            a s _ w a r n ( )
  53.  *
  54.  * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning
  55.  * in input file(s).
  56.  * Please only use this for when we have some recovery action.
  57.  * Please explain in string (which may have '\n's) what recovery was done.
  58.  */
  59.  
  60. #ifdef NO_VARARGS
  61. /*VARARGS1*/
  62. as_warn(Format,args)
  63. char *Format;
  64. {
  65.   if ( ! flagseen ['W'])    /* -W supresses warning messages. */
  66.     {
  67.       as_where();
  68.       _doprnt (Format, &args, stderr);
  69.       (void)putc ('\n', stderr);
  70.       /* as_where(); */
  71.     }
  72. }
  73. #else
  74. void
  75. as_warn(Format,va_alist)
  76. char *Format;
  77. va_dcl
  78. {
  79.   va_list args;
  80.  
  81.   if( ! flagseen['W'])
  82.     {
  83.       as_where();
  84.       va_start(args);
  85.       vfprintf(stderr, Format, args);
  86.       va_end(args);
  87.       (void) putc('\n', stderr);
  88.     }
  89. }
  90. #endif
  91. /*
  92.  *            a s _ f a t a l ( )
  93.  *
  94.  * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a fatal
  95.  * message, and locate stdsource in input file(s).
  96.  * Please only use this for when we DON'T have some recovery action.
  97.  * It exit()s with a warning status.
  98.  */
  99.  
  100. #ifdef NO_VARARGS
  101. /*VARARGS1*/
  102. as_fatal (Format, args)
  103. char *Format;
  104. {
  105.   as_where();
  106.   fprintf(stderr,"FATAL:");
  107.   _doprnt (Format, &args, stderr);
  108.   (void)putc ('\n', stderr);
  109.   /* as_where(); */
  110.   exit(42);            /* What is a good exit status? */
  111. }
  112. #else
  113. void
  114. as_fatal(Format,va_alist)
  115. char *Format;
  116. va_dcl
  117. {
  118.   va_list args;
  119.  
  120.   as_where();
  121.   va_start(args);
  122.   fprintf (stderr, "FATAL:");
  123.   vfprintf(stderr, Format, va_alist);
  124.   (void) putc('\n', stderr);
  125.   va_end(args);
  126.   exit(42);
  127. }
  128. #endif
  129.  
  130. /* end: messages.c */
  131.